import time
import pytest
import sqlite3

@pytest.fixture(scope="session")
def connect():
    conn = sqlite3.connect('funds.db')
    print("数据库连接成功")
    yield conn
    conn.close()
    print("数据库连接关闭")


@pytest.fixture(scope='function', autouse=True)
def run_time():
    t1_time = time.time()
    yield
    t2_time = time.time()
    print('总耗时：{}'.format(t2_time - t1_time))

def test_case1(connect):
    cursor = connect.cursor()
    sql = 'select count(1) from fund'
    cursor.execute(sql)
    rows = cursor.fetchone()
    x = 0
    for i in range(100000):
        x += 1
    result = rows[0]
    assert result == 11202


if __name__ == '__main__':
    pytest.main(["-s", "test_huangcui.py", "--html=./report/result.html"])